﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Home.aspx.cs" Inherits="Home" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<h2 align="center">Welcome to Airline Reservation System</h2>
<div align="center">
    Most
Popular Flights
    <asp:GridView ID="GridView1" runat="server" AllowSorting="True" 
        AutoGenerateColumns="False" DataKeyNames="FlightID" 
        DataSourceID="SqlDataSource1" Width="100%" BackColor="White" BorderColor="White" BorderStyle="Ridge" BorderWidth="2px" CellPadding="3" CellSpacing="1" GridLines="None">
        <Columns>
            <asp:BoundField DataField="FlightID" HeaderText="Flight ID" 
                InsertVisible="False" ReadOnly="True" SortExpression="FlightID">
            <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="50px" />
            </asp:BoundField>
            <asp:BoundField DataField="FROM" HeaderText="FROM" ReadOnly="True" 
                SortExpression="FROM">
            <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
            </asp:BoundField>
            <asp:BoundField DataField="TO" HeaderText="TO" ReadOnly="True" 
                SortExpression="TO">
            <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
            </asp:BoundField>
            <asp:BoundField DataField="Depart Time" DataFormatString="{0:t} {0:d}" 
                HeaderText="Depart Time" SortExpression="Depart Time">
            <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="120px" />
            </asp:BoundField>
            <asp:BoundField DataField="GMT" DataFormatString="GMT {0}" SortExpression="GMT">
            <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="50px" />
            </asp:BoundField>
            <asp:BoundField DataField="FlyHour" DataFormatString="{0} Hour(s)" 
                HeaderText="Fly Hour" SortExpression="FlyHour">
            <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="80px" />
            </asp:BoundField>
        </Columns>
        <RowStyle BackColor="#DEDFDE" ForeColor="Black" />
        <FooterStyle BackColor="#C6C3C6" ForeColor="Black" />
        <PagerStyle BackColor="#C6C3C6" ForeColor="Black" HorizontalAlign="Right" />
        <SelectedRowStyle BackColor="#9471DE" Font-Bold="True" ForeColor="White" />
        <HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#E7E7FF" />
    </asp:GridView>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:sqlString %>" 
        
        SelectCommand="SELECT TOP (10) Airline_Flight.FlightID, Airline_Flight.[Depart Time], COUNT(Airline_TicketDetail.TicketDetailID) AS count, Airline_Route.FlyHour, CAST(Airline_Cities.[City Name] AS VARCHAR(50)) + ' , ' + CAST(Airline_Cities.State AS VARCHAR(50)) + ',' + CAST(Airline_Cities.Country AS VARCHAR(50)) AS [FROM], CAST(Airline_Cities_1.[City Name] AS VARCHAR(50)) + ' , ' + CAST(Airline_Cities_1.State AS VARCHAR(50)) + ',' + CAST(Airline_Cities_1.Country AS VARCHAR(50)) AS [TO], Airline_Cities.GMT FROM Airline_Cities INNER JOIN Airline_Route ON Airline_Cities.CityID = Airline_Route.OriginalCityID INNER JOIN Airline_Schedule ON Airline_Route.RouteID = Airline_Schedule.RouteID INNER JOIN Airline_Flight ON Airline_Schedule.SchedueID = Airline_Flight.ScheduleID INNER JOIN Airline_Ticket ON Airline_Flight.FlightID = Airline_Ticket.FlightID INNER JOIN Airline_Cities AS Airline_Cities_1 ON Airline_Route.DestinationCityID = Airline_Cities_1.CityID INNER JOIN Airline_TicketDetail ON Airline_Ticket.TicketID = Airline_TicketDetail.TicketID WHERE (Airline_Ticket.TicketStatus = 'buy') OR (Airline_Ticket.TicketStatus = 'book') GROUP BY Airline_Flight.FlightID, Airline_Flight.[Depart Time], Airline_Route.FlyHour, Airline_Cities.[City Name], Airline_Cities.State, Airline_Cities.Country, Airline_Cities.GMT, Airline_Cities_1.[City Name], Airline_Cities_1.State, Airline_Cities_1.Country ORDER BY count DESC, Airline_Flight.[Depart Time] DESC">
    </asp:SqlDataSource>
</div>
</asp:Content>

